package it.xiuxian.homepage.presenter

import com.lzy.okgo.OkGo
import it.xiuxian.homepage.activity.ZiXunActivity
import it.xiuxian.homepage.bean.ZiXunBean
import it.xiuxian.lib.base.*
import it.xiuxian.lib.http.CallBackOption
import it.xiuxian.lib.http.HttpConfig
import it.xiuxian.lib.utils.EncodeUtils

import org.json.JSONObject

class ZiXunActivityPresenter:BasePresenter<ZiXunActivity>() {
    fun getList(pageNo:String,sort:String){
        var json1 = JSONObject()
        json1.put("pageNo",pageNo)
            .put("sort",sort)
        OkGo.post<BaseBean<ZiXunBean>>(HttpConfig.BASE_URL+"/appzixun/list")
            .params("encrypt", EncodeUtils.encodeAES(json1.toString()))
            .execute(object : CallBackOption<BaseBean<ZiXunBean>>() {}.loadBind(mView as ZiXunActivity).execute(
                object : ILoadBind<BaseBean<ZiXunBean>> {
                    override fun excute(bean: BaseBean<ZiXunBean>) {
                        if(bean.code==0){
                            (mView as ZiXunActivity).geData(bean.data.list)
                        }
                    }
                }
            ))
    }
}